Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force the creation of odoo_workdir and odoo_rootdir #90

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

JordiBForgeFlow
Copy link
Sponsor Member

@JordiBForgeFlow JordiBForgeFlow commented Jul 4, 2018

The parameters 'odoo_workdir', 'odoo_rootdir' and 'odoo_config_data_dir' are defaulted to be under /home/{odoo user}

odoo_workdir: "/home/{{ odoo_user }}/odoo"

But that is not the correct to place applications, according to https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard. In /home one should store user's personal files, not applications.

In my opinion a better place, according to my interpretation of the filesystem hierarchy standard, should be:
odoo_workdir: "/opt/odoo"
odoo_rootdir: "/opt/odoo/server"
odoo_config_data_dir: "/srv/odoo"

I can agree that this may not be necessarily the defaulted values. But the problem comes when I change the parameters to what I indicated above. In that case the playbook fails because there's no explicit task in the playbook that creates the odoo_workdir or odoo_rootdir.

In addition the odoo config file was hardcoded to be stored under /home/{odoo user}, but seems that /etc is generally a more accepted place to store config files. So I create a parameter 'odoo_config_file_dir' and force the existence during execution of the playbook.

Copy link
Collaborator

@sebalix sebalix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we should comply with the FHS.
Regarding the odoo_config_file_dir (and maybe the others), a danger is to set it to /etc/ (resulting to /etc/odoo.conf) and then Ansible will set the owner of /etc to odoo:odoo. Should we protect against such common places?
We have some old standard installations running with the configuration file in /etc/odoo.conf in fact (for sure having a subdirectory /etc/odoo is better...).

About buildout failures, I'm trying to fix that in https://github.com/osiell/odoo-buildout-example .


- name: Create odoo config file directory
file: path={{ odoo_config_file_dir }} state=directory
owner={{ odoo_user }} group={{ odoo_user }} force=yes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This task should not be executed for buildout installation, as anybox.recipe.odoo is in charge to create the config file in its own directory (./etc/odoo.cfg by default.).

@sebalix
Copy link
Collaborator

sebalix commented Jul 5, 2018

Buildout tests fixed.

@JordiBForgeFlow
Copy link
Sponsor Member Author

JordiBForgeFlow commented Jul 5, 2018

I have introduced some more changes according to your suggestions. My proposal is:

Filestore + downloaded modules and werkzeug sessions will be stored in {{ odoo_config_data_dir }}/{{ odoo_service }} (e.g. /srv/oca)
Therefore we try to ensure that a directory {{ odoo_config_data_dir }}/{{ odoo_service }} exists and is owned by {{ odoo_user }}

Application will be stored in {{ odoo_rootdir }}/{{ odoo_service }}/server (e.g. /opt/oca/server)
Therefore we try to ensure that a directory {{ odoo_rootdir }}/{{ odoo_service }}/server exists and is owned by {{ odoo_user }}

Configuration will be stored in {{ odoo_config_file_dir }}/{{ odoo_service }} (e.g. /etc/oca)
Therefore we try to ensure that a directory {{ odoo_config_file_dir }}/{{ odoo_service }} exists and is owned by {{ odoo_user }}

Odoo working dir will be stored in {{ odoo_workdir }}/{{ odoo_service }}
Therefore we try to ensure that a directory {{ odoo_workdir }}/{{ odoo_service }} exists and is owned by {{ odoo_user }}

@sebalix
Copy link
Collaborator

sebalix commented Jul 5, 2018

But odoo_config_data_dir is where the filestore + downloaded modules and werkzeug sessions are stored, they should not be saved under /etc/ but in /srv/odoo as you suggest, or /var/lib/odoo in Debian-like systems. Am I wrong?

@JordiBForgeFlow
Copy link
Sponsor Member Author

@sebalix Sorry, I corrected the texts.

@JordiBForgeFlow
Copy link
Sponsor Member Author

@sebalix Travis fails in some of the tests, but not sure if it is related to this changes.

@@ -12,10 +12,10 @@ odoo_init: True
odoo_init_env: {}
#VAR1: value1
#VAR2: value2
odoo_logdir: "/var/log/{{ odoo_user }}"
odoo_logdir: "/var/log"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove {{ odoo_user }}?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because that's the base directory that will be used as the basis to create the specific odoo log directory, in the task:

  • name: Create log directory
    file: path={{ odoo_logdir }}/{{ odoo_service }} state=directory
    owner={{ odoo_user }} group={{ odoo_user }} force=no
    tags:
    • odoo_log

Copy link
Collaborator

@sebalix sebalix Jul 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why not odoo_logdir = "/var/log/{{ odoo_service }}"?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because then someone could do odoo_logdir = "/var/log" by mistake, and then the role would change the permissions of the /var/log directory, that is shared.

The idea that I had in order to prevent this kind of errors is that the *dir variables point to the root dir. the final directory is root dir + {{ odoo_service }}

Copy link
Sponsor Member Author

@JordiBForgeFlow JordiBForgeFlow Jul 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, {{ odoo_service }} will be used as a subdir of:
/{{ odoo_logdir }}/{{ odoo_service }} => For logs
/{{ odoo_workdir }}/{{ odoo_service }} => For work dir
/{{ odoo_rootdir }}/{{ odoo_service }}/server => For the server

odoo_workdir: "/home/{{ odoo_user }}/odoo"
odoo_rootdir: "{{ odoo_install_type == 'buildout' and '/home/'+odoo_user+'/odoo/parts/odoo' or '/home/'+odoo_user+'/odoo/server' }}"
odoo_workdir: "/home/{{ odoo_user }}/{{ odoo_service }}"
odoo_rootdir: "{{ '/home/'+odoo_user+'/'+odoo_service }}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The odoo_rootdir is supposed to be the server directory (containing the odoo executable), which is /home/odoo/odoo/parts/odoo for buildout by default (need to be adapted), /home/odoo/odoo/server/ for standardandpip` (to adapt too). Or you want to change its meaning?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem to add absolute paths in a variable, is that someone could set odoo_rootdir = /opt and screw everything, because it would add permissions on odoo for the whole /opt.

@@ -39,7 +39,8 @@ odoo_postgresql_extensions:
- unaccent

# Standard installation/configuration options (odoo_install_type == 'standard')
odoo_config_file: "/home/{{ odoo_user }}/{{ odoo_service }}.conf"
odoo_config_file_dir: "/home/{{ odoo_user }}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use directly {{ odoo_config_file | dirname}} to get the directory path without adding another user option.
Feel free to create a new variable in ./vars/main.yml if you want a variable odoo_config_file_dir, these options are not supposed to be change by the user.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion {{ odoo_config_file }} should only contain the name of the config file. Because if you want to specify a certain subdir for the odoo config file, how can you possibly create that dir?

Same as above, for any path that you indicate you need a step that ensures that this path exists and is assigned to the right user.

And in order to ensure that people do now screw the standard linux, the paths indicated in parameters would not be created directly, but /{{ odoo_service }}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand now, thank you, so we have to drop the compatibility to achieve this, it wasn't clear and I was trying to keep this compatible.
A major release number is also required for such change (./meta/main.yml, to update to 2.0?).

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a problem, since it seems that ansible does not seem to support role versioning ansible/proposals#23

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was just to "warn" the users that this new version break the compatibility with the previous ones, nothing more :)

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we document that? will adding - version: 2.0 just work?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to document this change, you could add a page in the wiki telling how to stay compatible with old releases (list old variable values) and link it on the README? For the moment it's enough.

@@ -106,13 +107,13 @@ odoo_config_custom: {}
#your_option2: value2

# Pip installation options (odoo_install_type == 'pip')
odoo_pip_venv_path: "{{ odoo_workdir }}/sandbox"
odoo_pip_venv_path: "{{ odoo_workdir }}/{{ odoo_service }}/sandbox"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odoo_workdir already includes the odoo_service value.

odoo_pip_requirements_url: "file:///home/{{ odoo_user }}/requirements.txt"
odoo_pip_odoo_bin_path: "{{ odoo_pip_venv_path }}/bin/{{ (odoo_version | int) < 10 and 'odoo.py' or 'odoo' }}"

# Buildout installation options (odoo_install_type == 'buildout')
odoo_buildout_version: 2.10.0
odoo_buildout_venv_path: "{{ odoo_workdir }}/sandbox"
odoo_buildout_venv_path: "{{ odoo_workdir }}/{{ odoo_service }}/sandbox"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark.

@@ -25,7 +25,7 @@
- odoo_install_ssh

- name: Create log directory
file: path={{ odoo_logdir }} state=directory
file: path={{ odoo_logdir }}/{{ odoo_service }} state=directory
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If odoo_service should be part of the odoo_logdir directory, include it directly in this last option, this ensures that the "Create log directory" will effectively create the directory set in odoo_logdir, without any surprise.

- name: Create odoo data dir directory
file: path={{ odoo_config_data_dir }} state=directory
file: path={{ odoo_config_data_dir }}/{{ odoo_service }} state=directory
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark as for the "Create log directory" task / odoo_logdir option.

@@ -96,7 +96,7 @@ odoo_buildout_build_dependencies:
- libwebp-dev

odoo_buildout_venv_cmd: "virtualenv --no-setuptools --python=python3 {{ odoo_buildout_venv_path }}"
odoo_pip_venv_cmd: "virtualenv --python=python3 {{ odoo_pip_venv_path }}"
º: "virtualenv --python=python3 {{ odoo_pip_venv_path }}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants